package com.example.javabasic.thread.classone.demo4;

/**
 * 线程安全 数据共享
 * 线程同步
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{

           while(!Thread.currentThread().isInterrupted()){
               try {
                   System.out.println(Thread.currentThread().getName());
                   System.out.println(Thread.currentThread().isInterrupted());
                   Thread.sleep(500);
               } catch (InterruptedException e) {
                   break;
               }
           }
        },"666");
        thread.start();
        Thread.sleep(5000);
        thread.interrupt();
    }
}
